import { UserInfoAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        cartTotal: 0,
        userInfo:{
            nikName:"",
            coin:"--",
            handImg:require("../../assets/img/userImg.f8bbec5e.png")
        }
    },
    mutations:{
        changeUserInfo(state,payload){
            state.userInfo.nikName = payload.userInfo.nikName;
            state.userInfo.coin = payload.userInfo.coin;
            state.userInfo.handImg = payload.userInfo.handIm
            state.cartTotal = payload.cartTotal;
        },
        initUserInfo(state){
            state.cartTotal = 0,
            state.userInfo={
                nikName:"",
                coin:"--",
                handImg:require("../../assets/img/userImg.f8bbec5e.png")
            }
        }
    },
    actions:{
      async  asyncChangeUserInfo({commit},payload){
            let res = await UserInfoAPI()
            commit('changeUserInfo',res.data.data)
        }
    }
}